﻿using System;
using ComputationalCore.Impl.RandomGenerator.Enum;
using ComputationalCore.Interface.RandomGenerator;
using ComputationalCore.Interface.RandomGenerator.Factory;

namespace ComputationalCore.Impl.RandomGenerator.Factory
{
    public class RandomGeneratorFactory : IRandomGeneratorFactory
    {
        private static IRandomGeneratorFactory _instance = new RandomGeneratorFactory();

        private RandomGeneratorFactory() { }

        public static IRandomGeneratorFactory GetInstance()
        {
            return _instance;
        }

        public IRandomGenerator Create(RandomGeneratorType type)
        {
            switch (type)
            {
                case RandomGeneratorType.UNIFORM:
                    return new UniformRandomGenerator();
                case RandomGeneratorType.POISSON:
                    return new PoissonRandomGenerator();
                case RandomGeneratorType.ERLANG:
                    return new ErlangRandomGenerator();
                case RandomGeneratorType.GAUSSIAN:
                    return new GaussianRandomGenerator();
                default:
                    throw new ArgumentException();
            }
        }
        
        public IRandomGenerator Create(RandomGeneratorType type, params double[] varList)
        {
            switch (type)
            {
                case RandomGeneratorType.UNIFORM:
                    return new UniformRandomGenerator(varList[0], varList[1]);
                case RandomGeneratorType.POISSON:
                    return new PoissonRandomGenerator(varList[0]);
                case RandomGeneratorType.ERLANG:
                    return new ErlangRandomGenerator(varList[0], (int)varList[1]);
                case RandomGeneratorType.GAUSSIAN:
                    return new GaussianRandomGenerator(varList[0], varList[1]);
                default:
                    throw new ArgumentException();
            }
        }
         
    }
}
